package com.useeinfo.oa.modules.security.biz;

import com.useeinfo.framework.extend.biz.CrudBiz;
import com.useeinfo.framework.sugar.data.QueryParam;
import com.useeinfo.oa.modules.base.entity.Enterprise;
import com.useeinfo.oa.modules.security.dao.UserRoleEnterpriseDao;
import com.useeinfo.oa.modules.security.entity.SystemRole;
import com.useeinfo.oa.modules.security.entity.SystemUser;
import com.useeinfo.oa.modules.security.entity.UserRoleEnterprise;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class UserRoleEnterpriseBiz extends CrudBiz<UserRoleEnterpriseDao, UserRoleEnterprise> {

    /**
     * 获取用户角色公司数据
     *
     * @param systemUser 用户
     * @param role       角色
     * @param enterprise 公司
     * @return
     */
    public List<UserRoleEnterprise> getUserRoleEnterpriseList(SystemUser systemUser, SystemRole role, Enterprise enterprise) {
        QueryParam queryParam = new QueryParam();
        if (systemUser != null && systemUser.getId() != null) {
            queryParam.getSqlMap().put("userId", systemUser.getId() + "");
        }
        if (role != null && role.getId() != null) {
            queryParam.getSqlMap().put("roleId", role.getId() + "");
        }
        if (enterprise != null && enterprise.getId() != null) {
            queryParam.getSqlMap().put("enterpriseId", enterprise.getId() + "");
        }
        return this.findList(queryParam);
    }
}
